Here's a simple custom feature that I use often when editing Python in Emacs.
(defun nate/insert-comment-bar () "Insert '#' char from the current column up to `fill-column`. Useful for inserting bars in source code comments." (interactive) (let* ((rightward-cols (- fill-column (current-column)))) (if (>= rightward-cols 1) (dotimes (_ rightward-cols) (insert "#")))) (global-set-key (kbd "C-c B") #'nate/insert-comment-bar)
This makes it easy to write code that look like this:
def simple_geotransform(x_res, y_res, upper_left_lon, upper_left_lat, width_x, width_y): """ Convenience function to construct a simple geotransform with 0 row / column rotation. """ ################################################################## # Parameters of geotransform. Places the geotiff on the map. # See: https://gdal.org/tutorials/geotransforms_tut.html # NOTE: the upper left of the world map is -x, +y. ################################################################## pixel_width_ns = width_x / x_res pixel_width_we = width_y / y_res geotransform = [upper_left_lon, pixel_width_we, 0.0, upper_left_lat, 0.0, -1*pixel_width_ns] return GeotiffParams(x_res, y_res, geotransform)